import { observer } from 'mobx-react'
import React, { Component } from 'react'
import { Layout, Modal } from 'antd';
import { ExclamationCircleOutlined } from "@ant-design/icons";
import "./index.scss"
import userinfo from '../../mobx/userinfo';
import Head from "./head";
import SlideMenu from "./sider"
import { Route, Switch, Redirect } from 'react-router-dom';
import Home from '../home/home';
import Totle from '../totle/totle';
import Nursehas from '../nurse/has';
import Nursetotle from '../nurse/add';
import Nurseinfo from '../nurse/info';
import Guahaoinfo from '../payment/guahaoinfo';
import Guahao from '../payment/guahao';
import Money from '../payment/money';
import Talk from '../hospital/talk';
import People from '../hospital/people';
import Introduce from '../hospital/introduce';
import Youresult from '../nurse/youresult';

const { Content, Footer, Sider } = Layout;
@observer
class main extends Component {
    // token 验证
    componentDidMount() {
        // 登录后传递过来的登录人信息 （mobx）
        console.log(userinfo.userinfo)

        var token = sessionStorage.token
        console.log(token)
        if (token) {

        } else {
            Modal.confirm({
                title: "登录提醒!",
                icon: <ExclamationCircleOutlined />,
                content: "请前往登录",
                cancelButtonProps: {
                    disabled: true
                },
                onOk: () => {
                    this.props.history.push("./login")
                },
                onCancel: () => {
                    console.log("Cancel");
                }
            })
        }
    }
    render() {
        return (
            <Layout className="bigbox">
                <SlideMenu style={{ padding: 100 }}></SlideMenu>
                <Layout style={{ width: "80%" }}>
                    <Head></Head>
                    <Content style={{ padding: '0 24px', minHeight: 280 }}>
                        
                        <Switch>
                            <Route path="/main/totle" component={Totle} />
                            <Route path="/main/nurse" render={() => (
                                <Switch>
                                    <Route path="/main/nurse" exact component={Nursehas} />
                                    <Route path="/main/nurse/add" component={Nursetotle} />
                                    <Route path="/main/nurse/has" component={Nursehas} />
                                    <Route path="/main/nurse/info" component={Nurseinfo} />
                                    <Route path="/main/nurse/youresult" component={Youresult} />
                                </Switch>
                            )}
                            />
                            <Route path="/main/payment" render={() => (
                                <Switch>
                                    <Route path="/main/payment" exact component={Guahao} />
                                    <Route path="/main/payment/guahao" component={Guahao} />
                                    <Route path="/main/payment/guahaoinfo" component={Guahaoinfo} />
                                    <Route path="/main/payment/money" component={Money} />
                                </Switch>
                            )}
                            />
                            <Route path="/main/hospital" render={() => (
                                <Switch>
                                    <Route path="/main/hospital" exact component={Talk} />
                                    <Route path="/main/hospital/talk" component={Talk} />
                                    <Route path="/main/hospital/people" component={People} />
                                    <Route path="/main/hospital/introduce" component={Introduce} />
                                </Switch>
                            )}
                            />

                        </Switch>
                    </Content>
                    <Footer style={{ textAlign: 'center' }}>footer-footer-footer</Footer>
                </Layout>
            </Layout>
        )
    }
}
export default main